package cn.shengchao.cap.infrastructure.dao;

import cn.shengchao.cap.infrastructure.dao.po.ProductThirdCapOrderGrade;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


public interface ProductThirdCapOrderGradeDao extends BaseMapper<ProductThirdCapOrderGrade> {

    @Select("select ifnull(a.maxTime,0) " +
            "from  " +
            "(select max(a.graduation_year) as maxTime " +
            "            from product_third_cap_order_grade a  " +
            "            left join pay_order b on a.order_id=b.order_id  " +
            "            where a.user_id=#{userId} and b.`status`='PAY_SUCCESS' and a.deleted=0) a")
    int queryMaxOrderValidTimeForUserId(@Param("userId") Long userId);
}
